% delete one (jack knife) estimate
% of impedance and variances
% Reference Chave, A. D., and Thomson, D. J., 1989
% J. Geophys. Res., 94, 14215-14225
% AG Jones (LiMS)
% Latest date 04.03.2003

function[Zjack,d1diff,var] = jknfvar(Z,iflag),


	len = sum(iflag);
   Zall = sum(Z)/len;
   
   for j = 1:4,
      Zd1(:,j) = iflag.*(len*Zall(j)-Z(:,j))./(len-1);
   end;
   
   for j = 1:4,
        Zjack(j) = len*Zall(j) - ((len-1)/len)*sum(Zd1(:,j));
   end; 

	Zd1sum=sum(Zd1)/len;
   
	for j=1:4,
      d1diff(:,j)=abs(iflag.*(Zd1(:,j)-Zd1sum(j))).^2;
      var(j)=sum(d1diff(:,j))*(len/(len-1));
	end;
   

